package chapter01

object Test24_While5 {
  def main(args: Array[String]): Unit = {
    //计算1-1000的所有水仙花数
    //153 = 1*1*1+5*5*5+3*3*3
    var num = 100
    while(num<1000){
      val ge = num%10 //153%10=3
      val bai = num/100 //153/100=1
      val shi = num%100/10 //153%100=53/10=5
      if(ge*ge*ge+shi*shi*shi+bai*bai*bai==num){
        println(s"${num}是水仙花数")
      }
      num+=1
    }
  }
}
